import { Dialog } from "vant";
import lot from "@/tools/const.js";
import { logoutApi } from "@/api/lot.js";
export default {
  name: "indexHeader",
  components: {},
  data() {
    return {
      // logo
      img: lot.logo,
      //顶部背景
      indexBg: {
        backgroundImage: "url(" + require("@/assets/images/indexBg.png") + ")",
        backgroundRepeat: "no-repeat",
        backgroundSize: "cover",
      },
    };
  },
  created() {},
  mounted() {},
  methods: {
    // 退出
    logoutApi() {
      Dialog.confirm({
        message: "是否确定退出",
      })
        .then(() => {
          logoutApi().then((res) => {
            console.info("logoutApi注销出参：" + JSON.stringify(res));
            if (res.status === 200) {
              localStorage.removeItem("token");
              localStorage.removeItem("loginInfo");
              this.$router.push({ name: "login" });
            } else {
              this.$message({
                type: "error",
                message: res.msg,
                showClose: true,
                duration: 1200,
              });
            }
          });
        })
        .catch(() => {
          // on cancel
        });
    },
  },
};
